import $ from '../common';
Page({
  data: {
    // 相关功能的数组
    aboutArr: [{
        item: [{
          img: '../../image/image_222@2x.png',
          tile: '已选课程',
          id: 1
        }, {
          img: '../../image/image_11@2x.png',
          tile: '校园选课',
          id: 2
        }, {
          img: '../../image/image_223@2x.png',
          tile: '课程表',
          id: 3
        }, {
          img: '../../image/image_224@2x.png',
          tile: '在线请假',
          id: 4
        }]
      },
      {
        item: [{
          img: '../../image/image_225@2x.png',
          tile: '课堂风采',
          id: 5
        }, {
          img: '../../image/image_226@2x.png',
          tile: '作业',
          id: 6
        }, {
          img: '../../image/image_227@2x.png',
          tile: '课程评价',
          id: 7
        }, {
          img: '../../image/image_228@2x.png',
          tile: '收藏',
          id: 8
        }]
      }
    ],
    userinfo:[],
    unsign:[],
    current: 0,
  },
  //相关功能跳转
  openabout(e) {
    const {currentTarget:{dataset:{id}}} = e;
    switch (id) {
      case 1:
        $.navigateTo('/course/selectcourse')
        break;
      case 2:
        $.navigateTo('/campus/selectcourse')
        break;
      case 3:
        $.navigateTo('/schedule/index')
        break;
      case 4:
        $.navigateTo('/schedule/index')
        break;
      case 5:
        $.navigateTo('/classroom/mien')
        break;
      case 6:
        $.navigateTo('/classroom/homework')
        break;
      case 7:
        $.navigateTo('/classroom/estimate')
        break;
      case 8:
        // $.navigateTo('/campus/collection')
        $.navigateTo('/campus/selectcourse?type=collect')
        break;
    }
  },
  // 分享
  onShareAppMessage(res) {
    return {
      title: '课袋管家家长端',
      path: '/pages/index/index',
      imageUrl: 'https://sxzimgs.oss-cn-shanghai.aliyuncs.com/yingxiao/page/857f611a-d115-11ec-a9ca-00163e04cc20.jpeg'
    }
  },
  getuser(){//获取最近上课安排，学习动态，学习动态
    const{zonecode}=this.data
    $.get('/user/dynamic',{
      zonecode
    },res=>{
      this.setData({
        recentlessons:res.recentlessons,
        studentgrowings:res.studentgrowings,
        waiting_review_lessons:res.waiting_review_lessons
      })
    })
  },
  getusergroup(){//获取今日待办
    $.get('/user/group/agreements/unsign',{
      zonecode:this.data.zonecode
    },res=>{
      this.setData({
        unsign:res
      })
    })
  },
  // 相关功能
  gochooseaddress() { //选择地址
    $.navigateTo('/address/chooseaddress')
  },
  onLoad(e) {
    wx.removeStorageSync('$alreadyLoginWindow')
    this.getuser()
    this.getusergroup()
  },
  getuserstudent() { //获取_用户下认证子女

  },
  onShow() {
    this.setData({
      address: wx.getStorageSync('address') || '',
      zonecode: wx.getStorageSync('addresscode') || ''
    })
    // $.get('/user/students/certified', {
    //   zonecode:this.data.zonecode
    // }, res => {
    //   if(res.students.length==0){
    //     console.log('没学院');
    //   }else{

    //   }
    // })
    if(!wx.getStorageSync('addresscode') && wx.getStorageSync('token')){
      $.navigateTo('/address/chooseaddress')
    }
  }
})